package com.example.librarymanagementproject2.Common.config;

import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RabbitConfig
 * @Description TODO
 * @Author Kx
 * @Date 2025/10/22 20:09
 * @Version 1.0
 */
@Configuration
public class RabbitConfig {
    // 用户信息交换机
    public static final String USER_EXCHANGE = "user.exchange";

    // 用户添加的队列、路由键
    public static final String USER_LOGIN_QUEUE = "user.login.queue";
    public static final String USER_LOGIN_ROUTING_KEY = "user.login.key";

    // 用户修改的队列、路由键
    public static final String USER_OPERATION_QUEUE = "user.operation.queue";
    public static final String USER_OPERATION_ROUTING_KEY = "user.operation";

    // 图书信息交换机
    public static final String BOOK_EXCHANGE = "book.exchange";

    // 图书添加的队列、路由键
    public static final String BOOK_INSERT_QUEUE = "book.insert.queue";
    public static final String BOOK_INSERT_ROUTING_KEY = "book.insert.key";

    // 图书修改的队列、路由键
    public static final String BOOK_OPERATION_QUEUE = "book.operation.queue";
    public static final String BOOK_OPERATION_ROUTING_KEY = "book.operation.key";

    // 借阅记录交换机
    public static final String BORROW_RECORD_EXCHANGE = "borrowRecord.exchange";

    // 借阅记录成功后发送邮件信息队列、路由键
    public static final String BORROW_RECORD_SUCCESS_QUEUE = "borrowRecord.success.queue";
    public static final String BORROW_RECORD_SUCCESS_ROUTING_KEY = "borrowRecord.success.key";

    // 借阅记录修改队列、路由键
    public static final String BORROW_RECORD_OPERATION_QUEUE = "borrowRecord.operation.queue";
    public static final String BORROW_RECORD_OPERATION_ROUTING_KEY = "borrowRecord.operation.key";

    // 借阅记录成功后的延迟交换机、队列、路由键
    public static final String BORROW_RECORD_SUCCESS_DELAY_EXCHANGE = "borrowRecord.success.delay.exchange";
    public static final String BORROW_RECORD_SUCCESS_DELAY_QUEUE = "borrowRecord.success.delay.queue";
    public static final String BORROW_RECORD_SUCCESS_DELAY_ROUTING_KEY = "borrowRecord.success.delay.key";

    /**
     * 替换默认的SimpleMessageConverter序列化器
     */
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
